package com.lwq.designpattern.creationalPatterns.singletonPattern;

/**
 * @ClassName
 * @Description 懒汉式 单例模式
 * @Author liwq
 * @Date 2021/4/25 13:34
 * @Version 1.0
 */
public class SingletonLazy {
    private volatile static SingletonLazy instance;

    private SingletonLazy() {
    }

    public static SingletonLazy getInstance() {
        if (instance == null) {
            synchronized (SingletonLazy.class) {
                if (instance == null) {
                    instance = new SingletonLazy();
                }
            }
        }
        return instance;
    }

    public void showMessage() {
        System.out.println("创建型模式-单例模式-懒汉模式");
    }

}
